#ifndef TRACKWIDGET_H
#define TRACKWIDGET_H

#include <QWidget>
#include <QPen>
#include <QPainter>
#include <QDebug>
#include <QTimer>
#include "common.h"

class TrackWidget : public QWidget
{
    Q_OBJECT
public:
    explicit TrackWidget(QWidget *parent = 0);
    void resetDrawing();
    // Calling API
    void drawPath(const QList<BaseNode *> &nodeList, const PathGeometry& geo);
    void addInterpPoint(QPointF *point);

signals:

public slots:

protected:
    void paintEvent(QPaintEvent *event);

private:
    void drawNodePath();
    void drawTipText(QString tip);
    double findProjectionRatio();
    void findStartPoint(double &startX, double &startY, double ratio);
    void drawOneNode(QPainter* p, const BaseNode *node, double ratio,
                         double& current_x, double& current_y);
    void drawStartDirection(QPainter *p, const BaseNode* startNode, double ratio,
                            const double& cur_x, const double& cur_y);
    void drawInterpPath(QPainter *p, double ratio, QPointF startPoint);

    bool isInitState;
    QList<BaseNode*>* nodeList;
    PathGeometry geo;
    QList<QPointF*> interpolationPoints;

    QTimer* updateTimer;
};

#endif // TRACKWIDGET_H
